#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define N 1000005
using ll = long long;
#define MOD 1000000000
ll a[N];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < N; ++i) a[i] = 1;
    ll sum = k;
    for (int i = k; i <= n; ++i) {
        a[i] = sum;
        sum = (sum - a[i - k] + a[i]) % MOD;
        if (sum < 0) sum += MOD;
    }
    cout << a[n] << endl;
    return 0;
}
